package cn.tedu.charging.order.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class DelayCheckConfiguration {
    @Bean
    public Queue delayCheckQueue(){
        return QueueBuilder.durable("DELAY_BILL_QUEUE")
                .ttl(1000*60)
                .deadLetterExchange("DELAY_BILL_DL_EX")
                .deadLetterRoutingKey("DELAY_BILL_DL_RK").build();
    }
    @Bean
    public Queue delayCheckDlQueue(){
        return QueueBuilder.durable("DELAY_BILL_DL_QUEUE").build();
    }
    @Bean
    public Exchange delayCheckExchange(){
        return ExchangeBuilder.fanoutExchange("DELAY_BILL_EX").build();
    }
    @Bean
    public Exchange delayCheckDlExchange(){
        return ExchangeBuilder.directExchange("DELAY_BILL_DL_EX").build();
    }
    //绑定关系
    @Bean
    public Binding delayCheckBinding(){
        return BindingBuilder.bind(delayCheckQueue()).to(delayCheckExchange()).with("").noargs();
    }

    @Bean
    public Binding delayCheckDlBinding(){
        return BindingBuilder.
                bind(delayCheckDlQueue()).to(delayCheckDlExchange())
                .with("DELAY_BILL_DL_RK").noargs();
    }
}
